package com.party.core.service.commune.impl;

import com.party.common.paging.Page;
import com.party.core.dao.read.commune.CIntegralMedalReadDao;
import com.party.core.dao.write.commune.CIntegralMedalWriteDao;
import com.party.core.model.BaseModel;
import com.party.core.model.commune.CIntegralMedal;
import com.party.core.service.commune.ICIntegralMedalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Set;

/**
 * @program: party
 * @description: 积分类型服务实现
 * @author: Hua Qunhao
 * @create: 2019-08-12 14:32
 **/
@Service
public class CIntegralMedalService implements ICIntegralMedalService {

    @Autowired
    private CIntegralMedalReadDao cIntegralMedalReadDao;
    @Autowired
    private CIntegralMedalWriteDao cIntegralMedalWriteDao;

    @Override
    public String insert(CIntegralMedal cIntegralMedal) {
        BaseModel.preInsert(cIntegralMedal);
        BaseModel.preByInfo(cIntegralMedal.getCreateBy(),cIntegralMedal);
        boolean result = cIntegralMedalWriteDao.insert(cIntegralMedal);
        if (result) {
            return cIntegralMedal.getId();
        }
        return null;
    }

    @Override
    public boolean update(CIntegralMedal cIntegralMedal) {
        cIntegralMedal.setUpdateDate(new Date());
        return cIntegralMedalWriteDao.update(cIntegralMedal);
    }

    @Override
    public boolean deleteLogic(String id) {
        return false;
    }

    @Override
    public boolean delete(String id) {
        return cIntegralMedalWriteDao.delete(id);
    }

    @Override
    public boolean batchDeleteLogic(Set<String> ids) {
        return false;
    }

    @Override
    public boolean batchDelete(Set<String> ids) {
        return false;
    }

    @Override
    public CIntegralMedal get(String id) {
        return cIntegralMedalReadDao.get(id);
    }

    @Override
    public List<CIntegralMedal> listPage(CIntegralMedal cIntegralMedal, Page page) {
        return cIntegralMedalReadDao.listPage(cIntegralMedal,page);
    }

    @Override
    public List<CIntegralMedal> list(CIntegralMedal cIntegralMedal) {
        return cIntegralMedalReadDao.listPage(cIntegralMedal,null);
    }

    @Override
    public List<CIntegralMedal> batchList(Set<String> ids, CIntegralMedal cIntegralMedal, Page page) {
        return null;
    }
}
